package net.qiqbframework.config;

/**
 * 模块配置，具有独立性。同时可以访问全局配置
 */
public interface ModuleConfiguration {

    /**
     * 使用全局配置初始化模块配置。将启动或者关闭需要的逻辑添加到全局配置提供的启动或者关闭上。
     *
     * @param config 全局配置
     */
    void initialize(Configuration config);


    /**
     * Returns the actual module configuration instance. Usually, it is the instance itself. However, in case of module
     * configuration wrappers, we would like to provide the wrapped module configuration as the instance.
     *
     * @return the actual module configuration instance
     */
    default ModuleConfiguration unwrap() {
        return this;
    }

    /**
     * Checks whether this Module Configuration is of the given {@code type}.
     *
     * @param type a {@link Class} type to check the Module Configuration against
     * @return whether Module Configuration is of given {@code type}
     */
    default boolean isType(Class<?> type) {
        return type.isInstance(this);
    }
}
